//
//  StateCard.swift
//  GOFM
//
//  Created by siri on 2024/10/21.
//  Copyright © 2024 Glad. All rights reserved.
//

import SwiftUI

struct StateCard: View {
       var statusCode:Int
       var title:String
       var date:String
       var roomName:String

       var body: some View {
           HStack(spacing: 20) {
               // 时间轴
               Text("9:00").foregroundColor(Color(hex: "#b3b4b8")).background(TimeLine()).font(.system(size: 14))
               
               //  会议信息卡片  0: 已结束 1:进行中 2:未开始
               ZStack {
                   if (statusCode == 0) {
                       HStack {
                           
                       }.frame(width: 280,height: 45)
                           .background(RoundedRectangle(cornerRadius: 10 ).foregroundColor(Color(hex: "#f4c500"))).padding(.trailing,10)
                   }else if (statusCode == 1) {
                       HStack {
                           
                       }.frame(width: 280,height: 45)
                           .background(RoundedRectangle(cornerRadius: 10 ).foregroundColor(Color(hex: "#5ac8fa"))).padding(.trailing,10)
                   }else if (statusCode == 2) {
                       VStack (spacing: 0) {
                           HStack {
                           }.frame(width: 280,height: 22.5)
                               .background(RoundedCorners(color:Color(hex:  "#5ac8fa"),tl:10) ).padding(.trailing,1)
                           HStack {
                           }.frame(width: 280,height: 22.5)
                               .background(RoundedCorners(color:Color(hex:  "#f4c500"),bl:10)).padding(.trailing,1)
                       }.frame(width: 280,height: 45).padding(.trailing,10)
                       
                   }
                   HStack {
                       VStack {
                           Text("\(title)").font(.system(size: 15))
                           Text("\(date)").font(.system(size: 15))
                       }.frame(width: 135,height: 45,alignment: .leading)
                       VStack {
                           Text("\(roomName)").font(.system(size: 15))
                           if (statusCode == 0) {
                               Text("已结束").foregroundColor(Color(hex: "#d3d4d4")).font(.system(size: 15))
                           } else if (statusCode == 1) {
                               Text("进行中").foregroundColor(Color(hex: "#01b043")).font(.system(size: 15))
                           }else if (statusCode == 2) {
                               Text("未开始").foregroundColor(Color(hex: "#ffa62e")).font(.system(size: 15))
                           }
                       }
                   }.frame(width: 280,height: 45)
                       .background(RoundedRectangle(cornerRadius: 10 ).foregroundColor(.white))
               }
           }
       }
}

struct StateCard_Previews: PreviewProvider {
    static var previews: some View {
        StateCard(statusCode: 0,title:"部内定例",date: "09:00-10:00",roomName: "A311")
    }
}
